﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;

namespace StaffModule.Behavior {
    public class DataGridSelectedItemsBehavior : Behavior<DataGrid> {
        public IList SelectedItems {
            get => (IList)GetValue(SelectedItemsProperty);
            set => SetValue(SelectedItemsProperty, value);
        }

        public static readonly DependencyProperty SelectedItemsProperty =
            DependencyProperty.Register(nameof(SelectedItems), typeof(IList), typeof(DataGridSelectedItemsBehavior));

        protected override void OnAttached() {
            AssociatedObject.SelectionChanged += (s, e) => SelectedItems = AssociatedObject.SelectedItems;
        }
    }
}
